package org.nowcoder.huawei.c100;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;

/**
 * 56: 求满足条件的最长子串的长度
 */
public class HC056 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String var = br.readLine();
        solve(var);
    }

    public static void solve(String var) {
        int left = 0, right = 0;
        int maxLen = Integer.MIN_VALUE;
        boolean hasLetter = false;
        Deque<Integer> letterIdx = new ArrayDeque<>();
        while (right < var.length()) {
            char c = var.charAt(right);
            if (Character.isLetter(c)) {
                letterIdx.addLast(right);
                hasLetter = true;
                if (letterIdx.size() > 1) {
                    left = letterIdx.removeFirst() + 1;
                }
                if (left == right) {
                    right++;
                    continue;
                }
            }
            maxLen = Math.max(maxLen, right - left + 1);
            right++;
        }
        if (hasLetter) {
            System.out.println(maxLen);
        } else {
            System.out.println(-1);
        }
    }
}
